import 'package:flutter_easyloading/flutter_easyloading.dart';

enum CommonToastType {
  normal,
  success,
  error,
  info,
  activity,
  progress,
}

class CommonToast {
  static showToast(String msg) {
    _showToast(msg);
  }

  static showSuccess(String msg) {
    _showToast(msg, toastType: CommonToastType.success);
  }

  static showError(String msg) {
    _showToast(msg, toastType: CommonToastType.error);
  }

  static showActivity(String msg) {
    _showToast(msg, toastType: CommonToastType.activity);
  }

  static dismissActivity() {
    EasyLoading.dismiss();
  }

  static _showToast(
    String msg, {
    CommonToastType toastType = CommonToastType.normal,
    double progressValue = 0.3,
  }) async {
    switch (toastType) {
      case CommonToastType.normal:
        await EasyLoading.showToast(msg);
        break;
      case CommonToastType.success:
        await EasyLoading.showSuccess(msg);
        break;
      case CommonToastType.error:
        await EasyLoading.showError(msg);
        break;
      case CommonToastType.info:
        await EasyLoading.showInfo(msg);
        break;
      case CommonToastType.activity:
        await EasyLoading.show(status: msg);
        break;
      case CommonToastType.progress:
        await EasyLoading.showProgress(progressValue, status: msg);
        break;
    }
  }
}
